<template>
  <div>
    <el-form :model="config" label-width="120px">
      <el-row>
        <el-col :span="24">
          <el-form-item label="商城名称:">
            <el-input v-model="config.mallName" placeholder="商城名称" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="商城特色介绍:">
            <el-input v-model="config.mallSlogan" placeholder="商城介绍" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="底部设置:">
            <el-input v-model="config.mallFooter" type="textarea" :rows="4" show-world-limit maxlength="1000" placeholder="商城底部设置" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="访问统计:">
            <el-input v-model="config.visitStatistics" type="textarea" :rows="4" show-world-limit maxlength="50" placeholder="商城底部设置" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="客服QQ设置:">
            <el-input v-model="config.serviceQQ" placeholder="客服QQ设置" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="联系电话:">
            <el-input v-model="config.serviceTel" placeholder="联系电话" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="联系邮箱:">
            <el-input v-model="config.serviceEmail" placeholder="联系邮箱" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="版权所有:">
            <el-input v-model="config.version" placeholder="版权所有" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="热搜关键词:">
            <el-input v-model="config.hotWordsSearch" placeholder="热搜关键词" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="热搜广告词（商品）:">
            <el-input v-model="config.adsGoodsWordsSearch" placeholder="热搜广告词-商品" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="热搜广告词（店铺）:">
            <el-input v-model="config.adsShopWordsSearch" placeholder="热搜广告词-店铺" />
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="24">
          <el-form-item label="账号禁用关键字:">
            <el-input v-model="config.registerLimitWords" placeholder="账号禁用关键字" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="系统禁用关键字:">
            <el-input v-model="config.limitWords" placeholder="系统禁用关键字" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="商品审核敏感词:">
            <el-input v-model="config.sensitiveWords" placeholder="商品审核敏感词" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col style="text-align: right;">
          <el-button size="mini" icon="el-icon-check" type="primary" @click="dataFormSubmit()">确定</el-button>
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>
<script>
export default {
  data() {
    return {
      config: {
        mallName: '',
        mallSlogan: '',
        mallFooter: '',
        serviceQQ: '',
        visitStatistics: '',
        serviceTel: '',
        serviceEmail: '',
        version: '',
        hotWordsSearch: '',
        adsGoodsWordsSearch: '',
        adsShopWordsSearch: '',
        limitWords: '',
        registerLimitWords: '',
        sensitiveWords: ''
      }
    }
  },
  activated() {
    this.init()
  },
  methods: {
    init() {
      this.$http({
        url: this.$http.adornUrl('/sysconfig/getConfigs'),
        method: 'post',
        data: {}
      }).then(({ data }) => {
        this.config.mallName = data.result.mallName
        this.config.mallSlogan = data.result.mallSlogan
        this.config.mallFooter = data.result.mallFooter
        this.config.visitStatistics = data.result.visitStatistics
        this.config.serviceQQ = data.result.serviceQQ
        this.config.serviceTel = data.result.serviceTel
        this.config.serviceEmail = data.result.serviceEmail
        this.config.version = data.result.version
        this.config.hotWordsSearch = data.result.hotWordsSearch
        this.config.adsGoodsWordsSearch = data.result.adsGoodsWordsSearch
        this.config.adsShopWordsSearch = data.result.adsShopWordsSearch
        this.config.limitWords = data.result.limitWords
        this.config.registerLimitWords = data.result.registerLimitWords
        this.config.sensitiveWords = data.result.sensitiveWords
      })
    },
    dataFormSubmit() {
      this.$http({
        url: this.$http.adornUrl(`/sysconfig/setConfigs`),
        method: 'post',
        data: this.$http.adornData(this.config)
      }).then(({ data }) => {
        if (data && data.code === 0) {
          this.$message({
            message: '操作成功',
            type: 'success',
            duration: 1500,
            onClose: () => {
              this.visible = false
              this.$emit('refreshDataList')
            }
          })
        } else {
          this.$message.error(data.msg)
        }
      })
    }
  }
}
</script>
